package com.spic.business.ioc.controller;

import com.spic.business.ioc.domain.IocHazardousWasteTreatment;
import com.spic.business.ioc.service.IIocHazardousWasteTreatmentService;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 危废物处置情况数据IOCController
 *
 * @author spic
 * @date 2022-04-14
 */
@RestController
@RequestMapping("/ioc/treatment")
public class IocHazardousWasteTreatmentController extends BaseController
{
    @Autowired
    private IIocHazardousWasteTreatmentService iocHazardousWasteTreatmentService;

    /**
     * 查询危废物处置情况数据IOC列表
     */
//    @PreAuthorize(hasPermi = "ioc:treatment:list")
    @GetMapping("/list")
    public TableDataInfo list(IocHazardousWasteTreatment iocHazardousWasteTreatment)
    {
        startPage();
        List<IocHazardousWasteTreatment> list = iocHazardousWasteTreatmentService.selectIocHazardousWasteTreatmentList(iocHazardousWasteTreatment);
        return getDataTable(list);
    }

    /**
     * 导出危废物处置情况数据IOC列表
     */
//    @PreAuthorize(hasPermi = "ioc:treatment:export")
//    @Log(title = "危废物处置情况数据IOC", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IocHazardousWasteTreatment iocHazardousWasteTreatment) throws IOException
    {
        List<IocHazardousWasteTreatment> list = iocHazardousWasteTreatmentService.selectIocHazardousWasteTreatmentList(iocHazardousWasteTreatment);
        ExcelUtil<IocHazardousWasteTreatment> util = new ExcelUtil<IocHazardousWasteTreatment>(IocHazardousWasteTreatment.class);
        util.exportExcel(response, list, "危废物处置情况数据IOC数据");
    }

    /**
     * 获取危废物处置情况数据IOC详细信息
     */
//    @PreAuthorize(hasPermi = "ioc:treatment:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(iocHazardousWasteTreatmentService.selectIocHazardousWasteTreatmentById(id));
    }

    /**
     * 新增危废物处置情况数据IOC
     */
//    @PreAuthorize(hasPermi = "ioc:treatment:add")
//    @Log(title = "危废物处置情况数据IOC", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IocHazardousWasteTreatment iocHazardousWasteTreatment)
    {
        return toAjax(iocHazardousWasteTreatmentService.insertIocHazardousWasteTreatment(iocHazardousWasteTreatment));
    }

    /**
     * 修改危废物处置情况数据IOC
     */
//    @PreAuthorize(hasPermi = "ioc:treatment:edit")
//    @Log(title = "危废物处置情况数据IOC", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IocHazardousWasteTreatment iocHazardousWasteTreatment)
    {
        return toAjax(iocHazardousWasteTreatmentService.updateIocHazardousWasteTreatment(iocHazardousWasteTreatment));
    }

    /**
     * 删除危废物处置情况数据IOC
     */
//    @PreAuthorize(hasPermi = "ioc:treatment:remove")
//    @Log(title = "危废物处置情况数据IOC", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(iocHazardousWasteTreatmentService.deleteIocHazardousWasteTreatmentByIds(ids));
    }
}
